﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Mapeo;

using System.Data;
using System.Data.SqlClient;

namespace BE
{
    public class OperacionesSubnarNotasDesaprobadas:Controlador
    {
        public void CrearNota(Nota nota,NotaComplementaria notac)
        {
            using (ISession Sesion = m_SessionFactory.OpenSession())
            {
                using (ITransaction Trans = Sesion.BeginTransaction())
                {
                    try
                    {
                        Sesion.Save(nota);
                        Sesion.Save(notac);
                        Trans.Commit();
                    }
                    catch (Exception)
                    {
                        Trans.Rollback();
                        throw;
                    }
                }
            }
        }
        public void CrearNota(Nota nota)
        {
            using (ISession Sesion = m_SessionFactory.OpenSession())
            {
                using (ITransaction Trans = Sesion.BeginTransaction())
                {
                    try
                    {
                        Sesion.Save(nota);
                        Trans.Commit();
                    }
                    catch (Exception)
                    {
                        Trans.Rollback();
                        throw;
                    }
                }
            }
        }
        public void ActualizarPeriodo(Nota nota)
        {
            using (ISession Sesion = m_SessionFactory.OpenSession())
            {
                using (ITransaction Trans = Sesion.BeginTransaction())
                {
                    try
                    {
                        IQuery query = (IQuery)Sesion.GetNamedQuery("Cursor_Actulizar_Periodos");
                        query.SetParameter("In_Ciclo", nota.CICLOS);
                        query.SetParameter("In_CodigoAlumno", nota.Alumno.ID);
                        query.SetParameter("In_Especialidad", nota.Especialidad.ID);
                        query.List();
                        Trans.Commit();
                    }
                    catch (Exception)
                    {
                        Trans.Rollback();
                        throw;
                    }
                }
            }
        }





        //public void ActualizarFlagNotas()
        //{
        //    using (ISession Sesion = m_SessionFactory.OpenSession())
        //    {
        //        using (ITransaction Trans = Sesion.BeginTransaction())
        //        {
        //            try
        //            {
        //                IQuery query = (IQuery)Sesion.GetNamedQuery("ActulizaFlagNotas");
        //                query.List();
        //                Trans.Commit();
        //            }
        //            catch (Exception)
        //            {
        //                Trans.Rollback();
        //                throw;
        //            }

        //        }

        //    }

        //}

    }
}
